package cn.chenlh.fx.component;

import javafx.scene.control.TextArea;

/**
 * 文本展示框
 */
public class Div extends TextArea {


    public Div() {
        setEditable(false);
        setMaxWidth(300);
        setMinWidth(300);
        setHeight(100);
    }

    public Div(int w) {
        this();
        setWidth(w);
    }

    public void setWidth(int w) {
        setMaxWidth(w);
        setMinWidth(w);
    }

    public void setHeight(int h) {
        setMinHeight(h);
        setMaxHeight(h);
    }

    public void setSize(double w, double h) {
        setWidth(w);
        setHeight(h);
    }

    public void append(String line) {
        String raw = getText();
        if ("".equals(raw.trim())) {
            setText(line);
        } else {
            setText(raw + "\n" + line);
        }
    }

    public String getVal() {
        return getText().trim();
    }
}
